﻿package com.sgcc.nfc.lock.data.local.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.sgcc.nfc.lock.data.local.entity.OperationLogEntity
import kotlinx.coroutines.flow.Flow

@Dao
interface OperationLogDao {
    @Query("SELECT * FROM logs ORDER BY operationTime DESC")
    fun observeLogs(): Flow<List<OperationLogEntity>>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun upsertAll(logs: List<OperationLogEntity>)

    @Query("DELETE FROM logs")
    suspend fun clear()
}
